home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS19.ADF
/
HouseHold
/
HHInv.DOC
< prev
next >
Wrap
Text File
|
1989-01-27
|
24KB
|
427 lines
The Household Inventory System
By Brian Catley
The Household Inventory System is a collection of three inter-related
Amiga Basic programs which provide the means of maintaining an inventory
of household possessions, along with the capability of updating that
inventory and printing inventory reports in a number of possible
sequences. Program #1 is the main program which provides for the entry and
maintenance of inventory items, while Program #2 allows reports in any of
three sequences, and Program #3 is a file maintenance program which is used
to maintain the actual files of data; (as against the data itself). All
three programs provide ample online help facilities.
A little more specifically, Program #1 allows for the entry of
individual items; browsing through the file of data; and selecting any
record for modification or deletion. When deleted, a record is tagged as
such but is actually still available, (and may be restored), until the file
is reorganized. Program #2 prints inventory reports in entry, room, or
item sequence, and Program #3 provides a number of file maintenance options
such as reorganization, displaying the count of records in the file,
initialization, etc.
Program #1 uses just about all of the memory available to Basic
programs which explains why the other two functions were not included in
that program! Further, since a second program was needed (at least), why
not separate the major functions into distinct programs? Hence, there are
three of them!
Entering the Three Programs
Should you choose to enter the three programs from the reproduced
listings accompanying this article, there are a couple of things you should
note. (Please be aware these three programs are also available on an
Amicus disk should you prefer not to type in the rather lengthy listings.
See elsewhere in this magazine for more information regarding Amicus
disks).
Anyway, there are a number of subprograms which are common to all three
programs and there is simply no need to enter them all for each program.
So, before you get into entering the three main programs, enter Listing
#1. This listing is composed of the common subprograms, and when you have
finished entering it, be sure and save it with the "A" option.
For example, SAVE "subs",A. The "A" option causes the entered
subprograms to be saved in an ASCII format which will subsequently allow
them to be MERGEd with the other three programs when they are entered. Note
that you must enter an immediate SAVE command to accomplish this. The SAVE
and SAVE AS menu items do not allow the use of this option.
Once you have successfully entered this listing, proceed with Listings
#2, #3, and #4. These three listing are the main portions of the three
programs under discussion. When each has been entered, click in the Output
window and enter the immediate command MERGE "subs", and then save the
merged programs with an appropriate name. How about HInvMain, HInvPrint,
and HInvMaint?
If you receive an error message after entering the merge command, the
chances are you forgot to save "subs" with the "A" option. This is no
great problem. Just save what you have been working on, load "subs" (or
whatever you called it), re-save it with the "A" option, load what you were
working on previously, and issue the merge command again. When each of the
programs has been completed, be sure to save it before you try to RUN (or
execute) it.
One thing you must be aware of is that memory really is tight (if you
have a 512K machine) with the main program. If you have been doing a lot
of editing of other programs, it is quite probable there will not be enough
memory available for the program to execute successfully. Therefore, if
you receive an "out of memory" message, you should not presume there is an
error with the program. However, you will probably find that you have to
reboot the machine in order to get the program to run correctly. For better
or worse, this is the only way to free some of the memory that is allocated
during a number of functions (such as cut and paste), and is never freed
(presumably to save having to load it again).
Anyway, once all three programs have been entered and saved, you are
ready to start using them.
Using the Household Inventory System
Before we get into the whys and wherefores, a couple of general
comments are in order. The major purpose of any system such as this is to
keep a record of your household inventory for insurance purposes in case of
burglaries, fire, etc. This being the case, it does not make a lot of
sense to keep that record in the house itself! We strongly recommend that
you keep this record on a separate disk, and that you keep a copy of that
disk in a safe-deposit box, or somewhere equally safe. Once you have
initially created your inventory file, you will probably find it
appropriate to update that file once or twice a year, replacing the disk in
the safe deposit box at the same time.
To create this separate disk, simply initialize (or Format) the disk
you wish to use, and copy Amiga Basic and the three programs onto it. If
you wish, use this disk in place of your normal Basic disk to enter the
programs originally. In fact, this is a good idea because it keeps
everything separate right from the start. Don't forget to make backup
copies of this disk along with the copy you will be placing in the
safe-deposit box!
You will find the programs easy to use. All have help menus which are
available at all times, and which should be read in their entirety the
first time each program is used. Beyond this, other menus and various
gadgets provide a very straightforward working environment. Let's take a
look at each of the three programs so you will know what to expect when you
actually use them.
The Data Entry and Maintenance Program:
This is the main, and largest, of the three programs. Its purpose is
to provide you with the means of entering new inventory items, and updating
(changing and/or deleting) items you have previously entered. In doing
this, it makes extensive use of many of the Amiga's special features and
follows what is emerging as the "standard" Amiga user interface. The result
is that a lot of memory is used! In fact, you will need at least 512K of
memory, and even then things will be a little tight. What this means is
that you will probably be unable to have any other task, such as a clock,
running in the background, and if you have previously used some Amiga
functions which load disk based routines in to memory (such as speech, cut
and paste, etc) you may even find you have to reboot the machine. Some
memory usage notes follow:
-the default Basic program memory allocation of 25000 is just, and only
just, sufficient to hold the program.
-the first thing the program does is to give itself some more memory
for the arrays it will dimension. This, in turn, reduces the amount of
system heap space available for the high resolution screens and windows,
and the file buffers.
-The actual amount of memory required depends on the number of records
in the inventory file. By adjusting the SIZE command at the beginning you
may increase or decrease the size of the program space as it becomes
appropriate. Remember, as the program space increases, the heap space
decreases, and vice versa.
When you run the program, you will be presented with a title screen,
and a request to enter the date. Should you press the right mouse button
you will also see you have three menus available to you: Project, Help, and
Data Files.
If this is the first time you have used the programs, you should do as
the screen suggests and read all the Help menu items; you may also want to
select Initialize under the Data File menu to create your inventory file.
Should you not do the latter yourself, and no inventory file exists, the
program will create one for you automatically a little later. Normally,
this will only happen once but it does provide you with the means of
starting over should you ever wish to.
While on the subject, let's take a closer look at the Project and Data
File menus; (the Help menu is self explanatory). The Project menu has a
single item: Quit. And it does just that, terminating the program and
returning control to Basic. The Data File menu has the following items:
Initialize. A new and empty inventory file established. If a file
presently exists, you will be asked if it is OK to delete it before the new
one is created.
Update Count. The program keeps track of the number of records in the
inventory file by means of a single record "count" file. When adding
records to the file, this count file is NOT updated with every single
addition; instead, an internal counter keeps track of the number of records
being added, and the "count" file is only updated when you select a new
function or quit the program. The purpose of this menu item is to allow
you to force the "count" file to be updated from time to time when adding a
substantial number of new records. This provides a degree of protection in
case of a power failure, system crash, etc.
No. of Records. This item simply provides you with the current count
of committed and and non-committed records. To commit the non-committed
records, use the Update Count item described just above.
Well, it's now time to enter the date as requested. The request is to
enter it in form mm/dd/yy (e.g. 09/01/87 for Jan 9, 1987), however what is
actually entered is not edited, but is simply used to identify when records
in the file have been added and/or updated. So you may really enter
whatever you wish, except for a null value. Once the date has been
accepted, three gadgets will appear on the screen and you are into the meat
of the program. The three gadgets are:
Add: Selecting this gadget will allow you to add new inventory items
to the existing file. Once selected, an "Add a New Item" window will open,
and you will be prompted for the name of the item; the room the item
belongs in; the date of purchase; its original cost; its current worth; its
replacement cost; its serial number; and any comments you may wish to
include. Note that only the first two items are required, the remainder
may be left blank or updated at a later time. While entering information,
you may select from Cancel, OK, and Modify gadgets at any time.
Cancel does just that. The current item is forgotten, and you are
asked if you wish to enter another item, or if you wish to Quit.
OK accepts the item you have entered and adds it to the inventory
file.
Modify allows you to update the item you are entering before adding it
to the file; (should you enter an incorrect piece of information, for
example). Once selected, you will be presented with a window which
displays each piece of information included with the record in question.
To update a piece of information, (correct or add), just click in that
item's box and then edit the existing information or enter the new
information.
Once you have used any of the above three gadgets, you will then be given
a choice of another two: Add More and Quit.
Add More. This selection allows you to start entering a new item
into your inventory.
Quit. Selecting this item will cause the record count file to be
updated, (thereby committing all the records you have just entered), and
will subsequently return you to the title screen.
Note that dates are not entered manually, nor are they updateable.
Dates are handled automatically, using the date you entered when you first
initiated the program.
Review: Selecting this option will cause the entire inventory file to
be read into memory. Once this has been done, you will be presented with a
full sized window which displays the first 18 records in the file, along
with some further information about the file, a scroll bar on the right
hand side of the screen, and a "Finished" gadget in the upper right
corner. Selecting this latter gadget will return you to the title screen;
(the internal representation of the file is also erased).
The scroll bar consists of upper and lower arrow-heads with a "bar"
between them. Clicking on the arrow-heads will cause the display to move
up or down by a single record. The "bar" is used to display the position
of the 18 displayed records relative to the entire file. The bar itself is
colored blue, spans the space between the two arrow-heads, and represents
the full file of inventory records. The display of the 18 records on the
screen is represented by a smaller white bar which is superimposed on the
blue bar. The size of this white bar is the same percentage of the blue
bar as the 18 records are of the number of records in the file. Thus, if
the file consists of 18 records or less, the white bar will cover the blue
bar in its entirety; but, the more records there are in the file (over 18)
the smaller in length the white bar will become. So, by clicking in the
blue portion of the bar, you may choose any set of 18 records from the file
to display; (although you may have to fine tune with the arrow-heads).
Now that you can browse through the file, what can you do with the
records? Well, if you wish to do something (like modify or delete) with
one of the records on the screen, just click on it!
You will receive a display of the record with each field contained
within a box. There will also be three gadgets to choose from: Modify, OK,
and Delete. If you choose Modify, you will be requested to click in the
field you wish to update, and you may then update that field. When all is
well, select the OK gadget.
Should you wish to discard the record, just click in the Delete gadget;
you will then be asked if this is really what you want to do (just to be on
the safe side), and if you select yes the record will be "logically"
removed from the file. What this means is that the record is "marked" for
deletion, rather than actually (physically) being deleted. Subsequent
reviews of the inventory file will show deleted records with asterisks
between the fields of information. If you click on one of these records,
you will be told the record has been deleted and requested if you wish to
restore the record to the file. Just select the Yes or No gadget! Note
that logically deleted records will not be physically deleted from the file
until it is reorganized; see a little later in the article for more
information.
Selecting OK will return you to the original display. Please note that
the "Review" display will always reflect the file as it existed when Review
was originally selected; deletions or changes you may have made will not
show up until the file is re-reviewed at a later time.
Quit. Selecting this gadget provides the same result as selecting the
Project/Quit menu item: the program terminates and control is returned to
Basic.
The Print Reports Program:
This program has no special memory requirements, is entirely menu
driven, will provide you with inventory reports in any of Entry, Room, or
Item sequence, and will work with any printer supported by the Amiga.
Once invoked, you will be presented with a title screen which is
similar to that of The Data Entry and Maintenance Program; however, there
will be no gadgets to select, you must use the three menus.
The Project menu has a single Quit item which, when selected, will
terminate the program and return you to Basic. The Help menu provides
information about the options available under the third menu, and should be
read in its entirety before actually printing a report. The final menu
addresses the main purpose of the program and allows you to produce printed
reports of your inventory in the sequence in which you entered them; in
sequence by the room in which they reside; or in sequence by the items
themselves.
Probably the most important thing to note is that Order Entry reports
may only be produced before either of the other two reports are produced.
In fact, once a report in room or item sequence is requested, the Order
Entry option in made non-selectable. (If the inventory array is sorted, as
it must be for room or item sequence reports, it becomes impossible to
return it to its original order entry sequence without reloading it from
disk).
It may also be appropriate (even if a little obvious) to mention that a
printer must be attached to your Amiga in order to make effective use of
this program.
The File Maintenance Program:
Like the report program described above, this program has no special
memory requirements, and is entirely menu driven. Once again there are
three menus: The Project menu has a Quit item for terminating the program;
the Help menu provides information about using the third menu; while the
Maintenance menu itself provides a number of items designed to assist in
maintaining the file of inventory items. Note that this program is more
concerned with maintaining the inventory file itself, rather than the data
which is contained therein.
Within the Maintenance menu, you will find the following items:
Initialize: This repeats the function available in The Data Entry and
Maintenance Program. It effectively deletes any existing file of inventory
items and allows you to start from scratch, should you so desire.
Reorganize: This item will only be necessary after a number of records
have been "logically" deleted from the inventory file, and the time has
come to actually and physically remove them from the file. This is done by
copying the file and dropping the "logically" deleted records during the
process. Please note that once a file has been reorganized, it becomes
impossible to reclaim logically deleted records.
Record Count: This an informational item which simply provides you with
a count of the number of inventory records on file.
Update Count: This item will only be required if something out of the
ordinary happens to your inventory file and it gets out of step with the
count file. The system uses this single record count file to keep track of
the number of records in the inventory file. As a general rule, this one
record file will accurately reflect the number of inventory records being
carried. However, it is conceivable that the two could get out of step as
the result of some unexpected event, (such as a power failure). Should this
ever happen, just use this menu item to reset the count file.
This program will probably not require a lot of use, but don't forget
you have it. And if you do delete records from time to time, please don't
forget to reorganize the file occasionally!
Programming Notes
Most of the "interesting" programming techniques take place within the
various subprograms which are a part of the three programs. The three
Gadget subprograms and the GetIp subprogram are prime examples. Further,
these subprograms have all been explained in some detail in previous issues
of Amazing Computing. So, if you would like more information about these
subprograms, please refer back to the more recent issues of AC.
Elsewhere, variations on the basic gadgets have also been employed;
and they all appear in the Review window!
First, the area occupied by each record which is displayed is defined
as a gadget, but is never actually drawn. This allows us to check for
"clicks" on individual records without having actual gadgets on the screen!
Second, the scroll bar on the right side of the screen is really three
individual gadgets. The top and bottom "arrow heads" are square gadgets
which are drawn with the interior and border in the background color (so
you can't see them). Immediately following this, the triangles which you
see are drawn independently by the main program, in white. What this
means is that you can really click anywhere in the square rather than just
in the triangle! The middle rectangle is a "normal" gadget with the white
bar being superimposed on it, once again, by the main program.
The size of the white bar, in relation to the blue rectangle, represents
the number of records displayed, in relation to the total number of records
in the file. Further, the location of the white bar within the gadget
represents the location of the records displayed within the overall file.
To accomplish this, the GetGadget sets a global variable to the "y" value
of the mouse click. The DrawBar subroutine then uses this value to
determine exactly where to draw the white bar within the gadget.
Thirdly, the inventory file itself is a relative file which is always
read from, or written to, via a relative record number. Since the number of
records in the file is continually variable, the three programs need to be
able to keep track of exactly how many records have been stored at any one
time. This is done by having a second file which contains a single record
which indicates just how many records are in the main file. This, in turn,
makes it impossible to read beyond the end of the file. When a record is
deleted, a delete flag is set within the record.
Thus, the record is still available, (and may be reinstated), until the
file is reorganized when the deleted record is actually removed from the
file. If we didn't do this, we would have no alternative but to reorganize
the file each time a record was deleted, and this is really not a very good
idea, especially when the file starts to become fairly large! The only
other item of note in this area is that the count file is only updated when
the "Add" function is terminated, or when the appropriate menu item is
selected. Doing it after every record addition adds a tremendous amount of
overhead and is simply not worth it. This does open the door to allowing
the count and data files to get out of step. However, this should not
happen very often, and if it should, the Update Count menu item of the File
Maintenance Program will take care of it!
Other than what we have just mentioned, the programs are really very
straightforward, and a little time spent studying the listings should
provide a complete understanding of how the programs works.
Some Final Comments
If you have been looking for a sound, automated method of storing your
household inventory for insurance purposes; or if after reading this
article, it sounds like a good idea, I'm sure you'll find these three
programs very useful. Further, if you are at all interested in Basic
programming, studying these programs should also prove to be very
educational.
As I'm sure you can see, a substantial amount of time and effort went
into developing these three programs, and for that reason I would ask that
you do not modify the title screen in any shape or fashion. Thank you, and
enjoy!
P.S. This system was written and tested using the version of
AmigaBasic which accompanies Workbench 1.1. As of this writing, I have
only just received my copy of Workbench 1.2, and while all three programs
appear to function correctly, no exhaustive testing under 1.2 has been
performed. However, it does appears that AmigaBasic 1.2 uses a little more
memory than the previous version. This, in turn, means that memory
sensitive programs (such as the main program here), become even more
sensitive. Just beware!